import {
  request,
  setCookie
} from '../request';

// 登录方法
export const serverLogin = async (params) => {
  const {
    usercode,
    password
  } = params;

  try {
    const response = await request({
      url: `eis.login?service=loginService&method=mobileAuth&usercode=${usercode}&password=${password}`,
      method: 'get',
    });
    // 保存用户名到 cookie
    // setCookie('oausername', usercode);
    return response;
  } catch (error) {
    throw error; // 抛出错误以便外部处理
  }
}


export const scanCodeLogin = async (params) => {
  const {
    usercode,
    password
  } = params;

  try {
    const response = await request({
      url: `eis.pubsimple?service=scanCodeService&method=scanAuth&usercode=${usercode}&password=${password}`,
      method: 'get',
    });
    // 保存用户名到 cookie
    // setCookie('oausername', usercode);
    return response;
  } catch (error) {
    throw error; // 抛出错误以便外部处理
  }
}
